﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BestLifePOS_Core.DomainObjects;
using BestLifePOS_Core.Data.Fascade;

namespace BestLifePOS_PresentationLayer
{
    public partial class frm_Shift_Change1 : Form
    {
        public frm_Shift_Change1()
        {
            InitializeComponent();
        }


        public static void CALL()
        {

            //DataTable myDataTable = new DataTable();
            DataGrid GRD = new DataGrid();

            //DataColumn UnitCol = new DataColumn("unit");
            //DataColumn QtyCol = new DataColumn("qty");
            //DataColumn AmoCol = new DataColumn("amount");

            //UnitCol.DataType = typeof(int);
            //QtyCol.DataType = typeof(int);

            //myDataTable.Columns.Add(UnitCol);
            //myDataTable.Columns.Add(QtyCol);
            //myDataTable.Columns.Add(AmoCol);

            ////Set the Expression here
            //AmoCol.Expression = "unit * qty";



        }


        private void btnCal_Click(object sender, EventArgs e)
        {
            //CALL();
            int x = Convert.ToInt32(GRD.CurrentRow.Cells[0].Value);
            int y = Convert.ToInt32(GRD.CurrentRow.Cells[1].Value);
            int z = x * y;
            GRD.CurrentRow.Cells[2].Value = z;

        }

        private void GRD_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void btnTot_Click(object sender, EventArgs e)
        {
            // int a = Convert.ToInt32(GRD.CurrentRow.Cells[2].Value);

            // GRD.CurrentRow.Cells[2].Value = a;
            //show on lable
            decimal total = 0;

            foreach (DataGridViewRow row in GRD.Rows)
            {
                if (!row.IsNewRow && row.Cells["AM"].Value != null)
                {
                    total += (int)row.Cells["AM"].Value;
                }
            }

            lbltot.Text = total.ToString("N2");
            lblCashTot.Text = total.ToString("N2");
            //lblCashTot.Text = total.ToString();
            // lbltot.
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnDn_Click(object sender, EventArgs e)
        {
            Done();
        }

        private void Done()
        {
            addToSM();
        }

        private void addToSM()
        {

            Shift_Manager LVSM = CollectSMFigures();


        }

        private Shift_Manager CollectSMFigures()
        {

            //Disposal Lvdis = new Disposal();
            //    Lvdis.Disp_Id = txtDisId.Text;
            //    Lvdis.PL_Id = txtPLID.Text;
            //   // Lvdis.PL_Id = txtProName.Text;
            //    Lvdis.Qty = Convert.ToDecimal(txtQty.Text);
            //    Lvdis.Description = txtDes.Text;
            //    Lvdis.Status = cmbStat.Text;
            //    Lvdis.User_Id = "1";
            //    Lvdis.User_Modify = "1";
            //    Lvdis.Date_Create = System.DateTime.Now;
            //    Lvdis.Last_Modify = System.DateTime.Now;
            //   // Lvdis.Total = "";


            try
            {
                Shift_Manager LVSM = new Shift_Manager();
                LVSM.Credit_Card = Convert.ToDecimal(txtCrdcd.Text);
                LVSM.Cheque = Convert.ToDecimal(txtChq.Text);
              //  LVSM.Manager_Cash = Convert.ToDecimal(txtSM.Text);
                //  LVSM.des

                return LVSM;
            }
            catch
            {
                return null;
            }



        }

        private void txtChq_TextChanged(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                double first = 0.00;
                double second = 0.00;
                double third = 0.00;
                if (double.TryParse(lblCashTot.Text, out first) && double.TryParse(txtCrdcd.Text, out second) && double.TryParse(txtChq.Text, out third))
                    lblDraw.Text = (first + second + third).ToString("N2");
            }
            catch
            {
                MessageBox.Show("WTF");
            }
        }

        private void dfr(object sender, EventArgs e)
        {
            try
            {
                double first = 0.00;
                double second = 0.00;

                if (double.TryParse(lblDraw.Text, out first) && double.TryParse(lblDbTot.Text, out second))
                    lblDefr.Text = (first + second).ToString("N2");
            }
            catch
            {
                MessageBox.Show("WTF");
            }
        }

        private void lblDbTot_Click(object sender, EventArgs e)
        {
            DBVal();
        }

        private void DBVal()
        {
            
        string DbtotL; 

            DbtotL = Shift_ManagerDAO.GetTotfrmTerm(lblDbTot.Text);
            lblDbTot.Text = DbtotL;

        }

        private void lblDraw_Click(object sender, EventArgs e)
        {

        }

        private void btnDfr_Click(object sender, EventArgs e)
        {
            try
            {
                double first = 0.00;
                double second = 0.00;

                if (double.TryParse(lblDbTot.Text, out first) && double.TryParse(lblDraw.Text, out second))
                    lblDefr.Text = (first - second).ToString("N2");
            }
            catch
            {
                MessageBox.Show("WTF");
            }
        }

        private void lblDefr_Click(object sender, EventArgs e)
        {

        }
  

        }

 }

